<%--
  Created by IntelliJ IDEA.
  User: a
  Date: 2025/8/28
  Time: 14:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
           //1.发送异步请求，获得集合：
           $.get("projectInfo/showdt","indexpage="+1,function (ph) {
                        showdt(ph);
           });

           //2.点击 查询按钮，发送异步请求，获得集合：
           $("[value='查询']").click(function () {
               var val=$("select").val();
               $.get("projectInfo/showdt",{"status":val,"indexpage":1},function (ph) {
                        showdt(ph);
               });
           });

        });

        //3.点击 b标签，发送异步请求,获得集合：
        $(document).on("click","input[name]",function () {
            var val=$("select").val();
            var indexpage=$(this).attr("name");
            $.get("projectInfo/showdt",{"status":val,"indexpage":indexpage},function (ph) {
                showdt(ph);
            });
        });


        //重用 数据显示方法：
        function showdt(ph) {
            JSON.stringify(ph);
            $("tbody").empty();
            for (var i = 0; i <ph.listIndex.length ; i++) {
                var str;
                if(ph.listIndex[i].status==0){
                   str= "                <th><a href='ajaxUpdatePro.jsp?pid="+ph.listIndex[i].pid+"'>审核</a></th>\n" ;
                }else{
                    str= "                <th></th>\n" ;
                }

                $("            <tr>\n" +
                    "                <th>"+ph.listIndex[i].pid+"</th>\n" +
                    "                <th>"+ph.listIndex[i].pname+"</th>\n" +
                    "                <th>"+ph.listIndex[i].startdate+"</th>\n" +
                    "                <th>"+ph.listIndex[i].enddate+"</th>\n" +
                    "                <th>"+ph.listIndex[i].status+"</th>\n" +
                    str +
                    "            </tr>").appendTo("tbody");
            }


            $("tfoot td").empty();
            if(ph.pageIndex!=1){
                $("<input type='button' value='首页' name='1'>").appendTo("tfoot td");
                $("<input type='button' value='上一页' name='"+(ph.pageIndex-1)+"'>").appendTo("tfoot td");
            }
            if(ph.pageIndex!=ph.pageCount){
                $("<input type='button' value='下一页' name='"+(ph.pageIndex+1)+"'>").appendTo("tfoot td");
                $("<input type='button' value='尾页' name='"+ph.pageCount+"'>").appendTo("tfoot td");
            }
            $("<b>第"+ph.pageIndex+"页/共"+ph.pageCount+"页</b>").appendTo("tfoot td");
        }
    </script>
</head>
<body>

申报状态<select name="status">
            <option value="-1">全部</option>
            <option value="0">已申报</option>
            <option value="1">审核中</option>
            <option value="2">已审核</option>
        </select>
        <input type="button" value="查询" >


    <table>
        <caption>申报项目列表</caption>
        <thead>
            <tr>
                <th>项目编号</th>
                <th>项目名称</th>
                <th>项目开始时间</th>
                <th>项目结束时间</th>
                <th>项目状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody></tbody>
        <tfoot>
            <tr>
                <td colspan="6"></td>
            </tr>
        </tfoot>
    </table>

</body>
</html>
